package org.naigu.peach.dal.dao.impl;

import guda.grape.autogen.common.BaseDAO;
import org.naigu.peach.dal.dao.ReplyDAO;
import org.naigu.peach.dal.dataobject.ReplyDO;
import guda.grape.autogen.common.page.BaseQuery;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ReplyDAOImpl extends BaseDAO implements ReplyDAO {

    @Override
	public Long insert(ReplyDO reply) {
	      try {
                return (Long) getSqlMapperW().insert("reply.insert",reply);
          } catch (Exception e) {
                throw new RuntimeException(e);
          }

	}

    @Override
	public ReplyDO getReplyById(Long replyId) {
	    return (ReplyDO)getSqlMapClientTemplate().queryForObject("reply.getReplyById", replyId);
	}

    @Override
	public boolean delReplyById(Long replyId) {
	    int num = 0;
        try {
            num = getSqlMapperW().delete("reply.delReplyById",replyId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        if(num>0){
            return true;
        }else{
            return false;
        }
	}

    @Override
	public List<ReplyDO> getReplyByIds(List idsList) {
        Map m = new HashMap();
        m.put("idsList",idsList);
		return getSqlMapClientTemplate().queryForList("reply.selectByIds", m);
	}

    @Override
	public void cleanAutoIncrement(Long replyId) {
	    try {
            getSqlMapperW().update("reply.cleanAutoIncrement",replyId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
	}

    @Override
    public List<ReplyDO> selectForPage(BaseQuery baseQuery) {
        return getSqlMapClientTemplate().queryForList("reply.selectForPage", baseQuery);
    }

    @Override
    public int countForPage(BaseQuery baseQuery) {
        return (Integer)getSqlMapClientTemplate().queryForObject("reply.countForPage",baseQuery);
    }

    @Override
    public void updateByIdSelective(ReplyDO reply) {
        try {
            getSqlMapperW().update("reply.updateByIdSelective",reply);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}

